<?php
/**
 * @property boolean $isAdmin
 * @property boolean $isSuperAdmin
 * @property User $user
 */
class WebUser extends CWebUser{
	private $_model;

	public function isAdminUser() {
			return $this->getState('isAdminUser');  
	}
	public function getFullName(){
		$user = $this->loadUser(Yii::app()->user->id);
    	return $user->employee_name;
	}

	public function getLevel(){
		$user = $this->loadUser(Yii::app()->user->id);
    	return $user->level;
	}

	public function getAllowAccount(){
		$level=Yii::app()->session['user_detail']['level'];
		return in_array($level, array('admin','accounting'))? true:false;
	}

	protected function loadUser($id=null)
    {
        if($this->_model===null)
        {
            if($id!==null)
                $this->_model=User::model()->findByPk($id);
        }
        return $this->_model;
    }
}
?>